export default {
  state: {
    tabsList: [
      {
        path: '/home',
        name: 'home',
        label: '首页',
        icon: 's-home',
      },
    ],
    currentTab: null, //当前选择的tab标签
  },
  mutations: {
    //点击菜单栏后添加面包屑和tag标签

    selectTab(state, tab) {
      if (tab.name !== 'home') {
        state.currentMenu = tab
        const result = state.tabsList.findIndex((item) => item.name === tab.name)
        if (result === -1) {
          state.tabsList.push(tab)
        }
      } else {
        state.currentMenu = null
      }
    },
    //删除tag标签
    closeTab(state, tab) {
      const index = state.tabsList.findIndex((item) => item.name === tab.name)
      state.tabsList.splice(index, 1)
    },
  },
}
